package com.thuanhoang.boo;

import com.boo.service.AccountService;

import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.view.View;
import android.view.Window;
import android.widget.Button;
import android.widget.EditText;

public class RegisterActivity extends FragmentActivity{
	EditText edtUserName, edtPhone;
	Button btnLogin,btnFacebook, btnCreateAcc, btnForgotPass;
	
	@Override
	protected void onCreate(Bundle arg0) {
		super.onCreate(arg0);
		requestWindowFeature(Window.FEATURE_NO_TITLE);
		setContentView(R.layout.activity_account);
		findViewById();
		
	}
	
	private void findViewById(){
		edtUserName 		= (EditText)findViewById(R.id.edt_username);
		edtPhone 		= (EditText)findViewById(R.id.edt_phone);
		
		btnLogin 		= (Button)findViewById(R.id.btn_login);
		btnFacebook 	= (Button)findViewById(R.id.btn_loginWithFacebook);
		btnCreateAcc 	= (Button)findViewById(R.id.btn_account);
		btnForgotPass 	= (Button)findViewById(R.id.btn_createAccount);
	}
	
	public void btnClicked(View v){
		switch (v.getId()) {
		case R.id.btn_login:
			String userName = edtUserName.getText().toString();
			String phone = edtPhone.getText().toString();
			
			if(userName==null || phone==null || userName.equals("") || phone.equals("")){
				// show dialog confirm
				Builder build = new Builder(this).setCancelable(true).setTitle("Request Info").setMessage("User Name and Password is not empty.").setNegativeButton("OK", new OnClickListener() {
					
					
					@Override
					public void onClick(DialogInterface dialog, int which) {
						dialog.dismiss();
					}
				});
				build.create().show();
				break;
			}
			AccountService accService = new AccountService(this);
			accService.register(userName,phone);
			break;
		case R.id.btn_account:
			
			break;
		case R.id.btn_forgotPassword:
			
			break;
		default:
			break;
		}
	}
}
